package cn.zhaozhiqi.controller.remote;

import cn.zhaozhiqi.pojo.domain.DriverSummary;
import cn.zhaozhiqi.remote.api.IDriverFeignClient;
import cn.zhaozhiqi.remote.dto.DriverSummaryDto;
import cn.zhaozhiqi.result.JSONResult;
import cn.zhaozhiqi.service.IDriverSummaryService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class DriverFeignClientImpl implements IDriverFeignClient {
    @Autowired
    private IDriverSummaryService summaryService;

    /**
     *
     * @param id
     * @return
     */
    @Override
    public JSONResult<DriverSummaryDto> getDriverSummery(Long id) {
        //将查到的数据属性拷贝到DriverSummaryDto
        DriverSummary summary = summaryService.getById(id);
        DriverSummaryDto driverSummaryDto = new DriverSummaryDto();
        BeanUtils.copyProperties(summary,driverSummaryDto);
        return JSONResult.success(driverSummaryDto);
    }
}
